package br.com.agiledev.webscrum.action;

import java.util.Arrays;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

import br.com.agiledev.webscrum.entity.User;

@SuppressWarnings("serial")
@Name("userSearchMB")
@Scope(ScopeType.PAGE)
public class UserSearchAction extends QueryAction<User> {

    private static final String EJBQL = "select us from User us";
    private static final String[] RESTRICTIONS = {"lower(us.nome) like lower(concat(#{userSearchMB.user.nome}, '%'))", "lower(us.login) like lower(concat(#{userSearchMB.user.login}, '%'))"};
    private static final String ORDER_COLUMN = "us.nome";
    
    private User user;
    
    public UserSearchAction() {
	setEjbql(EJBQL);
	setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
	setOrderColumn(ORDER_COLUMN);
    }
    
    //Get's / Set's
    public User getUser() {
	if(user == null) {
	    user = new User();
	}
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

 
}